<template>
  <div class="device-log-container">
    <el-button
      icon="el-icon-arrow-left"
      size="small"
      @click="goBack"
    >返回</el-button>
    <div class="device-log-detail">
      <el-form
        :inline="true"
        :model="updateForm"
        ref="updateForm"
      >
        <el-form-item label="日志编号">{{ updateForm.id }}</el-form-item>
        <el-form-item label="设备名称">{{ updateForm.deviceName }}</el-form-item>
        <el-form-item label="活动日志内容">{{ updateForm.message }}</el-form-item>
        <el-form-item label="活动日志详情">{{ updateForm.detail }}</el-form-item>
        <el-form-item label="创建时间">{{ updateForm.createdAt }}</el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { Message } from 'element-ui';
import { parseError } from '../../../utils';
import { getDeviceActivityLogDetailApi } from '../../../api/deviceActivityLog';
import { MomentFormat, SortType } from '../../../constants/common';
export default {
  data() {
    return {
      btnLoading: false,
      updateForm: {
        id: 0,
        deviceName: '',
        message: '',
        detail: '',
        createdAt: ''
      }
    };
  },
  created: function() {
    getDeviceActivityLogDetailApi(this.$route.params.id)
      .then(res => {
        this.updateForm.id = res.id;
        this.updateForm.deviceName = res.device_name;
        this.updateForm.message = res.message;
        this.updateForm.detail = res.detail;
        this.updateForm.createdAt = moment(res.created_at).format(MomentFormat);
      })
      .catch(error => Message.error(parseError(error)));
  },
  methods: {
    goBack() {
      this.$router.go(-1);
    }
  }
};
</script>

<style lang="scss" scoped>
.device-log-container {
  padding: 15px;
  .el-form {
    display: flex;
    flex-direction: column;
    > el-form-item {
      padding: 30px 30px;
    }
  }
  .paging-footer {
    padding: 15px 0;
  }
  .device-log-detail {
    padding: 10px;
    background-color: #fff;
    margin-top: 20px;
  }
}
</style>
